<template>
  
</template>

<script>
import { getdefaultComic, getcomicDetail } from "@/api/api";
export default {
  name: "Zhuiman",
  data() {
    return {
      defaultComicData: [],
      ComicData: [],
      ids:""
    };
  },
  created() {
    //获取书架默认漫画列表
    getdefaultComic()
      .then(res => {
        this.defaultComicData = res.data.data;
      })
      .catch(err => {
        console.log(err);
      });
    //获取漫画小说的详情内容
    this.ids = JSON.parse(localStorage.getItem("ids"));
    if (this.$root.typeIds.length == 0) {
        this.getId(this.ids, this.ComicData);
    } else {
      this.getId(this.$root.typeIds, this.ComicData);
    }
  },
  methods: {
    getId(id, data) {
      if (id) {
        id.forEach(item => {
          if (item == "") {
            return;
          }
          getcomicDetail(item)
            .then(res => {
              data.push(res.data.data);
            })
            .catch(err => {
              console.log(err);
            });
        });
      }
    },
    //删除对应书籍
    deleteComic(id) {
      for (let i = 0; i < this.ids.length; i++) {
        if (this.ids[i] == id) {
          this.ids.splice(i, 1);
          localStorage.setItem("ids", JSON.stringify(this.ids));
        }
      }
      //删除书籍移出书库收藏
      this.ComicData = [];
      this.getId(this.ids, this.ComicData);
    }
  }
};
</script>

<style lang="scss" scoped>
</style>